/**
 * @author        Nicolas Bottarini <nicolasbottarini@gmail.com>, 404 <http://www.proyecto404.com>
 * @version       $Rev: 3 $
 * @lastrevision  $Date: 2011-09-12 16:45:37 +0000 (Mon, 12 Sep 2011) $	 
 */
package com.proyecto404.core {
	import com.proyecto404.core.exception.InvariantException;
	import com.proyecto404.core.exception.PostConditionException;
	import com.proyecto404.core.exception.PreConditionException;
	import com.proyecto404.core.exception.AssertionException;

	/**
	 * @static
	 */
	public class Check {
		private static var _argument:Argument = new Argument();
		
		public static function require(assertion:Boolean, message:String = "Precondition Failed", inner:Exception = null):void {
			if (!assertion) {
				throw new PreConditionException(message, inner);
			}
		}
		
		public static function ensure(assertion:Boolean, message:String = "Postcondition Failed", inner:Exception = null):void {
			if (!assertion) {
				throw new PostConditionException(message, inner);
			}
		}
		
		public static function invariant(assertion:Boolean, message:String = "Invariant Failed", inner:Exception = null):void {
			if (!assertion) {
				throw new InvariantException(message, inner);
			}
		}
		
		public static function assert(assertion:Boolean, message:String = "Assertion Failed", inner:Exception = null):void {
			if (!assertion) {
				throw new AssertionException(message, inner);
			}
		}
		
		public static function get argument():Argument {
			return _argument;
		}
	}
}